Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Use Opendal driver in Http driver#311

Merged
NickCao merged 13 commits intomainfrom
opendal-in-http
Feb 27, 2025
Merged

Use Opendal driver in Http driver#311
NickCao merged 13 commits intomainfrom
opendal-in-http

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Feb 26, 2025

Summary by CodeRabbit

  • Refactor
    • Streamlined the HTTP components by removing direct file management actions to focus solely on server control.
  • Tests
    • Simplified the testing setup to ensure a more direct and reliable interaction with the server and enhanced test coverage for file operations.
  • Chore
    • Introduced new dependencies to support enhanced composite storage functionality.
  • New Features
    • Added methods for writing and reading byte data directly to and from remote files.
  • Documentation
    • Updated API reference to reflect changes in file writing methods and added assertions for data integrity.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2025

Walkthrough

The changes refactor the HTTP driver and client components by removing direct file management functionality. The HttpServerClient now inherits from CompositeClient, and its file handling methods have been removed. Similarly, the HttpServer class has been modified to eliminate asynchronous file operations in favor of initializing an Opendal storage instance. The testing infrastructure has been simplified by replacing asynchronous fixtures with a synchronous http fixture using the serve utility. Additionally, new dependencies for the composite driver and yarl have been added in the project's configuration.

Changes

File(s) Change Summary
packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py Updated HttpServerClient to inherit from CompositeClient (was DriverClient). Removed file management methods: list_files, put_file, put_local_file, and delete_file.
packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py In HttpServer, removed asynchronous file methods: put_file, delete_file, and list_files. Added initialization of an Opendal storage instance via self.children["storage"] in the __post_init__ method.
packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py Replaced temporary asynchronous server fixture with a synchronous http fixture (using serve). Updated test function signatures and streamlined file upload and deletion tests to directly interact with http.storage and use tmp_path.
packages/jumpstarter-driver-http/pyproject.toml Added new dependencies: "jumpstarter-driver-composite" and "yarl>=1.18.3".
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py Introduced BytesIOStream class for managing byte streams. Updated OpendalFile methods for clarity and added new methods write_bytes and read_bytes. Renamed existing methods for consistency.
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py Restructured tests to use a new opendal fixture for client setup. Added multiple new test functions covering various file operations like reading and writing bytes, file properties, and metadata.
packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver_test.py Simplified file writing process in test_tftp_file_operations by removing local file creation and directly writing to TFTP storage using write_bytes.
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/common.py Modified is_file and is_dir methods in EntryMode to return public attributes instead of private ones, changing the source of truth for file and directory status.
packages/jumpstarter/jumpstarter/common/grpc.py Reformatted return statement in aio_secure_channel function for improved readability without changing logic.
docs/source/api-reference/drivers/opendal.md Updated example to write bytes directly to a remote file using opendal.write_bytes, simplifying the process and adding an MD5 hash assertion for verification.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test Client
    participant S as HttpServer
    participant O as Opendal Storage

    T->>S: Start Server (via new http fixture)
    S->>O: Initialize storage in __post_init__
    T->>O: Write file directly to storage
    O-->>T: Return file URL
    T->>O: Delete file via storage.delete()
Loading

Possibly related PRs

Suggested reviewers

  • bennyz
  • mangelajo

Poem

I'm a rabbit on the run, codes neatly aligned,
Hopping over file methods that we left behind.
With Opendal storage my carrots now reside,
New fixtures and tests keep me hopping with pride.
A joyful leap in refactoring, a celebration so bright,
CodeRabbit cheers these changes—hop, hop, all is right!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8988367 and 052cf5b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (2 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (3 hunks)
  • packages/jumpstarter-driver-http/pyproject.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/jumpstarter-driver-http/pyproject.toml
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (3)
packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (3)

3-6: Appropriate import changes for the refactoring.

The import changes properly support the refactored functionality:

  • CompositeClient for the new inheritance structure
  • PathBuf from the Opendal common module for path handling
  • URL from yarl for safe URL construction

These imports align well with the PR objective of using Opendal driver in the HTTP driver.


10-10: Good architectural change using composition.

Changing the inheritance from DriverClient to CompositeClient is a positive architectural shift that eliminates redundant file management code and leverages standardized functionality. This aligns with the principle of favoring composition over inheritance where appropriate.


59-73:

Details

❓ Verification inconclusive

Well-implemented file upload method with Opendal integration.

The new put_file method effectively:

  • Integrates with Opendal for storage operations
  • Provides flexibility with the optional operator parameter
  • Uses proper path abstraction with PathBuf
  • Constructs the return URL safely using the yarl library
  • Includes comprehensive documentation

The implementation is clean and concise, delegating the actual file operations to the storage object which aligns with the PR's objective.


🏁 Script executed:

#!/bin/bash
# Check if any call sites of the old put_file method exist that might need updating
rg -l "\.put_file\s*\(\s*['\"][\w\d\._-]+['\"]" --type py

Length of output: 63


File Upload Method Implementation – Please Verify Call Sites

The implementation of the put_file method in packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py is clean, well-documented, and effectively integrates the opendal operator. The method correctly delegates file operations to the storage object, uses the optional operator parameter to enhance flexibility, and safely constructs the return URL using the yarl library.

Action Item:

  • Although our initial search for call sites using the literal-string pattern did not return any results, please manually verify (or use a broader search pattern) across the codebase to ensure that no outdated invocations of put_file remain.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 26, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 052cf5b
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67c0af3938919d0008ecba66
😎 Deploy Preview https://deploy-preview-311--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (1)

37-37: Consider graceful handling for Opendal initialization failures.
While this assignment is correct, it might be worth adding error handling in case the Opendal instantiation fails unexpectedly (e.g., invalid arguments or file system permission issues).

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (1)

35-35: Remove debug print statement.

This print statement appears to be debugging code that was accidentally left in the final version.

-    print(http.storage.stat(filename))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 115351d and 65c2c89.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (1 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (2 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (3 hunks)
  • packages/jumpstarter-driver-http/pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Redirect rules - jumpstarter-docs
  • GitHub Check: Header rules - jumpstarter-docs
  • GitHub Check: Pages changed - jumpstarter-docs
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (7)
packages/jumpstarter-driver-http/pyproject.toml (1)

13-13: Confirm compatible versions for new dependency.
Adding "jumpstarter-driver-composite" is consistent with the refactoring toward a composite approach. However, please ensure that this dependency is compatible with any existing constraints or usage patterns within the project.

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (1)

7-7: Validate Opendal import is installed and properly configured.
Ensure the jumpstarter-driver-opendal dependency is appropriately pinned and installed so this import remains functional in all environments.

packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (1)

3-7: Inheritance from CompositeClient appears consistent.
Switching to CompositeClient aligns well with removing direct file management responsibilities. This architectural decision seems appropriate for multi-driver setups.

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (4)

14-20: Improved fixture design with proper resource management.

The new http fixture using the serve utility provides better encapsulation and cleaner resource management than the previous implementation. The start() and stop() calls within a try/finally block ensure proper cleanup regardless of test outcome.


31-33: Verify the file writing behavior.

The code is opening a file in binary write mode ("wb") but writing a string path (str(tmp_path / local_filename)) rather than the actual file content. This seems inconsistent with the test's expectation that retrieved_content == test_content on line 46.

If the intent is to copy the test content to the storage, consider this approach instead:

-    file = http.storage.open(filename, "wb")
-    file.write(str(tmp_path / local_filename))
-    file.close()
+    with open(tmp_path / local_filename, "rb") as source:
+        with http.storage.open(filename, "wb") as dest:
+            dest.write(source.read())

Or if this is part of the Opendal interface design, please add a comment explaining this behavior.


24-51: LGTM: Successful refactoring to use Opendal storage API.

The test has been successfully refactored to use the Opendal storage interface via http.storage for all file operations (open, list, delete). This aligns with the PR's objective of using the Opendal driver in the HTTP driver.


54-63: LGTM: Tests updated to use pytest's native tmp_path fixture.

The tests for host configuration and root directory creation have been updated to use pytest's built-in tmp_path fixture instead of a custom temporary directory fixture. This is a good practice that simplifies the test code.

Copy link
Copy Markdown
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions.

Comment thread packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py Outdated
Comment thread packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (1)

37-37: Good modularization using Opendal for storage

Replacing the direct file handling methods with Opendal storage is a good architectural improvement. This change:

  1. Delegates file storage responsibilities to a specialized component
  2. Reduces code duplication
  3. Provides a consistent API for file operations across different drivers

The implementation correctly initializes the Opendal driver with the filesystem scheme using the same root directory.

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (1)

30-30: Debug print statement in test code

There's a debug print statement that should be removed before merging.

-    print(http.storage.stat(filename))
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65c2c89 and f8f2ffd.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • docs/source/api-reference/drivers/opendal.md (1 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (1 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (2 hunks)
  • packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (3 hunks)
  • packages/jumpstarter-driver-http/pyproject.toml (1 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (4 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (2 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver_test.py (1 hunks)
  • packages/jumpstarter/jumpstarter/common/grpc.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/jumpstarter/jumpstarter/common/grpc.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/jumpstarter-driver-http/pyproject.toml
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (18)
docs/source/api-reference/drivers/opendal.md (1)

16-18: Good streamlining of file operations in documentation example

The updated example demonstrates the new direct approach to file operations using Opendal. The code now uses write_bytes to directly write content to files rather than using temporary files, which simplifies the usage pattern.

I like the addition of the hash verification, which serves as both documentation and validation of the write operation.

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver_test.py (1)

27-27: Simplified file operation in test

The test now directly writes bytes to storage using tftp.storage.write_bytes() instead of creating temporary files. This is more concise and aligns with the Opendal-based approach being adopted across the codebase.

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (2)

38-40: Clearer file path handling in tests

The updated approach of explicitly creating a source file and using write_from_path is more explicit about the data flow and makes the test easier to understand. This matches the refactored API better than the previous approach.


56-56: Consistent API naming with write operations

The change to read_into_path mirrors the naming convention used for writing (write_from_path), creating a more consistent API for file operations. The names now clearly indicate the direction of data flow.

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver.py (1)

7-7: Appropriate dependency import added

Adding the Opendal driver import is necessary for the new storage approach being implemented.

packages/jumpstarter-driver-http/jumpstarter_driver_http/client.py (2)

3-3: New dependency on composite driver added

The HttpServerClient now inherits from CompositeClient instead of what appears to be DriverClient previously. This aligns with the PR objective to use Opendal driver for file handling.


7-7: Inheritance changed from DriverClient to CompositeClient

This inheritance change removes direct file management capabilities from HttpServerClient and leverages the composite pattern instead, which is consistent with the PR objectives.

packages/jumpstarter-driver-http/jumpstarter_driver_http/driver_test.py (6)

5-5: Added serve utility for simplified test setup

Using the serve utility simplifies the test infrastructure by providing a cleaner context manager approach.


13-20: Simplified test fixture with synchronous approach

The new http fixture replaces the previous asynchronous server fixture with a simpler synchronous implementation using the serve utility. This makes the test setup more maintainable.


24-24: Updated test signature to use new fixtures

The test now accepts the new http fixture and tmp_path instead of the previous server fixture.


28-33: Replaced file operations with storage API calls

File operations now use the storage interface from the composite client, which aligns with the PR objectives. However, consider adding a helper method that handles both writing the file and returning the URL in one step, as mentioned in past review comments.

You could add a helper method to the client that combines these operations:

def put_file_and_get_url(self, filename, content):
    self.storage.write_bytes(filename, content)
    return f"{self.get_url()}/{filename}"

43-46: File deletion now uses storage API

File deletion and listing now use the storage interface methods, which is consistent with the refactoring approach.


49-59: Updated test methods to use tmp_path

The host configuration and root directory creation tests have been properly updated to use tmp_path instead of the previous temp_dir, maintaining test functionality while simplifying the approach.

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (5)

21-39: Added BytesIOStream for bytes handling

The new BytesIOStream class provides a clean implementation of the ObjectStream interface for handling byte operations, which is essential for the refactoring.


56-61: Added helper method for path operator selection

The __fs_operator_for_path method provides a consistent way to handle both absolute and relative paths, improving code reusability.


63-69: Renamed methods for clarity and added path operator support

The methods have been renamed from write/read to write_from_path/read_into_path to more clearly describe their functionality, and they now use the new path operator helper method.

Also applies to: 74-80


84-98: Added byte-level read/write methods

The new write_bytes and read_bytes methods provide essential functionality for direct byte handling, which supports the HTTP driver refactoring.

Note that read_bytes could be simplified by using a cleaner stream handling approach, but the current implementation works correctly.


161-180: Added client-level methods for byte and file operations

These new client methods provide a higher-level interface for read/write operations with proper resource management using the closing context manager. The parameter naming convention with / for positional-only parameters is well-applied.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (4)

23-24: Consider moving test constants to the fixture

These test constants could potentially be moved into the fixture or a separate constants section to better organize the test file structure.


35-44: Verify path existence before writing

The test could be more robust by checking if directories exist before creating files. Consider adding checks to ensure the test paths are properly set up.

 def test_driver_opendal_read_write_path(opendal, tmp_path):
     src = tmp_path / "src"
     dst = tmp_path / "dst"
 
+    # Ensure parent directories exist
+    src.parent.mkdir(parents=True, exist_ok=True)
+    dst.parent.mkdir(parents=True, exist_ok=True)
+
     src.write_bytes(test_content)
 
     opendal.write_from_path(test_file, src)
     opendal.read_into_path(test_file, dst)
 
     assert dst.read_bytes() == test_content

118-124: Add assertions for empty directories

The test verifies listing and scanning with populated directories, but it would be more comprehensive to also test empty directories behavior.

 def test_driver_opendal_file_list_scan(opendal):
+    # Test empty root directory first
+    assert sorted(opendal.list("/")) == ["/"]
+    assert sorted(opendal.scan("/")) == ["/"]
+
     opendal.create_dir("a/b/c/")
     opendal.create_dir("d/e/")
 
     assert sorted(opendal.list("/")) == ["/", "a/", "d/"]
     assert sorted(opendal.scan("/")) == ["/", "a/", "a/b/", "a/b/c/", "d/", "d/e/"]

126-138: Add verification for presign_write if supported

The test covers presign_read and presign_stat, but it would be good to also test presign_write if the capability is available.

 def test_driver_opendal_presign(tmp_path):
     with serve(Opendal(scheme="http", kwargs={"endpoint": "http://invalid.invalid"})) as client:
         capability = client.capability()
 
         assert capability.presign_read
         assert client.presign_read("test", 100) == PresignedRequest(
             url="http://invalid.invalid/test", method="GET", headers={}
         )
 
         assert capability.presign_stat
         assert client.presign_stat("test", 100) == PresignedRequest(
             url="http://invalid.invalid/test", method="HEAD", headers={}
         )
+        
+        # Test presign_write if supported
+        if capability.presign_write:
+            presign_write_result = client.presign_write("test", 100)
+            assert isinstance(presign_write_result, PresignedRequest)
+            assert presign_write_result.method in ["PUT", "POST"]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8f2ffd and 8988367.

📒 Files selected for processing (3)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (4 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/common.py (1 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (6)
packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/common.py (1)

26-30: Clean refactoring from private to public attributes.

The implementation now uses public attributes entry_is_file and entry_is_dir (declared on lines 14-15) instead of what were likely private attributes (_is_file, _is_dir). This maintains the same public method interface while making the code more maintainable and consistent with Python conventions.

packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (5)

17-20: Well-designed test fixture approach

Using a pytest fixture for the Opendal client setup improves code organization and allows for better reuse across multiple test functions. The scope is appropriately set to "function" to ensure a clean state for each test.


27-32: Good coverage of basic read/write operations

This test effectively verifies both content integrity and hash verification using multiple algorithms. The assertions are comprehensive and test the core functionality.


47-62: Good testing of seek/tell functionality

This test effectively verifies file position operations. The test correctly checks both position and content after seeking.

One minor suggestion: consider adding a direct seek to position 0 test case as well, as this is a common operation.


64-85: Comprehensive file property testing

The test covers all important file handle properties for both read and write modes. Good job ensuring that the file is properly closed after operations and verifying the closed state.


88-116: Well-structured metadata operation test

This test thoroughly covers file metadata operations including existence checks, stat operations, and file manipulation (copy, rename, delete). The directory operations are also well tested.

@NickCao NickCao merged commit 5a3ed68 into main Feb 27, 2025
@NickCao NickCao deleted the opendal-in-http branch February 27, 2025 20:37
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants